package com.danskin.wechat.api.client;

import java.util.Map;
import java.util.UUID;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.danskin.wechat.util.HttpClientUtil;
import com.danskin.wechat.util.LogUtil;


public class ApiClient {
	
	//代码格式化
	public static JSONObject sendGet(String url,Map<String, String> param) {
		String uuid = UUID.randomUUID().toString().replace("-", "");
		LogUtil.info("\n---get---"+ uuid +"---\nurl:" + url);
		String result = HttpClientUtil.doGet(url, param);
		LogUtil.info("\n---get---"+ uuid +"---\nresult:\n" + result);
		return JSON.parseObject(result);
	}
	public static void sendGet2(String url,String paramStr) {
		String uuid = UUID.randomUUID().toString().replace("-", "");
		LogUtil.info("\n---get---"+ uuid +"---\nurl:" + url);
		String result = HttpClientUtil.sendGet(url, paramStr);
		LogUtil.info("\n---get---"+ uuid +"---\nresult:\n" + result);
		//return JSON.parseObject(result);
	}
	
	public static JSONObject sendPost(String url, String data) {
		String uuid = UUID.randomUUID().toString().replace("-", "");
		LogUtil.info("\n---post---" + uuid + "---\nurl:" + url + "\nparam:" + data);
		String result = HttpClientUtil.doPostJson(url, data);
		LogUtil.info("\n---post---" + uuid + "---\nresult:\n" + result);
		return JSON.parseObject(result);
	}
	
	public static String sendPostForWx(String url, String data) {
		String uuid = UUID.randomUUID().toString().replace("-", "");
		LogUtil.info("\n---post---" + uuid + "---\nurl:" + url + "\nparam:" + data);
		String result = HttpClientUtil.doPostJson(url, data);
		LogUtil.info("\n---post---" + uuid + "---\nresult:\n" + result);
		return result;
	}

	
//	public static JSONObject sendPostJson(String url, String data) {
//		String uuid = UUID.randomUUID().toString().replace("-", "");
//		logger.info("\n---post---" + uuid + "---\nurl:" + url + "\nparam:" + data);
//		String result = HttpClientUtil.doPostJson(url, data);
//		logger.info("\n---post---" + uuid + "---\nresult:\n" + result);
//		return JSON.parseObject(result);
//	}
	
}
